//
//  MyDriverCell.m
//  Zhiche-Carriage
//
//  Created by LeeBruce on 16/12/1.
//  Copyright © 2016年 LeeBruce. All rights reserved.
//

#import "MyDriverCell.h"
#import <Masonry.h>

#define leftMar 18
#define heightMar 30 * kHeight
#define widthMar 80 * kHeight


@implementation MyDriverCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initSubviews];
    }
    
    return self;
}

-(void)initSubviews
{
    //姓名
    UILabel *nameLable = [self labelWithBackgroundColor:WhiteColor textColor:carScrollColor textAlignment:NSTextAlignmentLeft numberOfLines:1 text:@"姓名" fontSize:14];
    nameLable.frame = CGRectMake(leftMar, 0, widthMar, heightMar - 0.5);
    [self.contentView addSubview:nameLable];
    
    self.nameLabel = [self labelWithBackgroundColor:WhiteColor textColor:littleBlackColor textAlignment:NSTextAlignmentLeft numberOfLines:1 text:@"" fontSize:13];
    self.nameLabel.frame = CGRectMake(CGRectGetMaxX(nameLable.frame), 0, 250 * kWidth, heightMar);
    [self.contentView addSubview:self.nameLabel];
    
    //电话
    
    UILabel *phoneLabel = [self labelWithBackgroundColor:WhiteColor textColor:carScrollColor textAlignment:NSTextAlignmentLeft numberOfLines:1 text:@"电话" fontSize:14];
    phoneLabel.frame = CGRectMake(leftMar, CGRectGetMaxY(nameLable.frame), widthMar, heightMar);
    [self.contentView addSubview:phoneLabel];
    
    
    self.phoneLabel = [self labelWithBackgroundColor:WhiteColor textColor:littleBlackColor textAlignment:NSTextAlignmentLeft numberOfLines:1 text:@"" fontSize:13];
    self.phoneLabel.frame = CGRectMake(CGRectGetMaxX(phoneLabel.frame), CGRectGetMinY(phoneLabel.frame), 250 * kWidth, heightMar - 0.5);
    [self.contentView addSubview:self.phoneLabel];

    
    //工号
    UILabel *numberLabel = [self labelWithBackgroundColor:WhiteColor textColor:carScrollColor textAlignment:NSTextAlignmentLeft numberOfLines:1 text:@"驾照初领时间" fontSize:14];
    numberLabel.frame = CGRectMake(leftMar, CGRectGetMaxY(phoneLabel.frame), widthMar, heightMar);
    [self.contentView addSubview:numberLabel];
    
    self.numberLabel = [self labelWithBackgroundColor:WhiteColor textColor:littleBlackColor textAlignment:NSTextAlignmentLeft numberOfLines:1 text:@"" fontSize:13];
    self.numberLabel.frame = CGRectMake(CGRectGetMaxX(numberLabel.frame), CGRectGetMinY(numberLabel.frame), 250 * kWidth, heightMar -0.5);
    [self.contentView addSubview:self.numberLabel];
    
    
    //身份证号
    UILabel *identifyLabel = [self labelWithBackgroundColor:WhiteColor textColor:carScrollColor textAlignment:NSTextAlignmentLeft numberOfLines:1 text:@"身份证号" fontSize:14];
    identifyLabel.frame = CGRectMake(leftMar, CGRectGetMaxY(numberLabel.frame), widthMar, heightMar);
    [self.contentView addSubview:identifyLabel];
    
    self.identifyLabel = [self labelWithBackgroundColor:WhiteColor textColor:littleBlackColor textAlignment:NSTextAlignmentLeft numberOfLines:1 text:@"" fontSize:13];
    self.identifyLabel.frame = CGRectMake(CGRectGetMaxX(identifyLabel.frame), CGRectGetMinY(identifyLabel.frame), 250 * kWidth, heightMar -0.5);
    [self.contentView addSubview:self.identifyLabel];
    
    //驾照类型
    
    UILabel *styleLabel = [self labelWithBackgroundColor:WhiteColor textColor:carScrollColor textAlignment:NSTextAlignmentLeft numberOfLines:1 text:@"准驾类型" fontSize:14];
    styleLabel.frame = CGRectMake(leftMar, CGRectGetMaxY(identifyLabel.frame), widthMar, heightMar);
    [self.contentView addSubview:styleLabel];
    
    self.styleLabel = [self labelWithBackgroundColor:WhiteColor textColor:littleBlackColor textAlignment:NSTextAlignmentLeft numberOfLines:1 text:@"" fontSize:13];
    self.styleLabel.frame = CGRectMake(CGRectGetMaxX(identifyLabel.frame), CGRectGetMinY(styleLabel.frame), 250 * kWidth, heightMar - 0.5);
    [self.contentView addSubview:self.styleLabel];
    
    
    
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(styleLabel.frame) + 5 * kHeight, screenWidth, 0.5)];
    [self.contentView addSubview:label];
    label.backgroundColor = LineGrayColor;
    
    
    //删除按钮

    self.deleteButton = [self buttonWithText:@"删 除" textColor:carScrollColor fontSize:16 textAlignment:UIControlContentHorizontalAlignmentCenter backgroundColor:GrayColor];
    [self.contentView addSubview:self.deleteButton];
    
    self.deleteButton.frame = CGRectMake(screenWidth - 90 * kWidth, CGRectGetMinY(label.frame) + 10 * kHeight, 72 * kHeight, 30 * kHeight);
    self.deleteButton.layer.cornerRadius = 5;
    self.deleteButton.layer.borderColor = carScrollColor.CGColor;
    self.deleteButton.layer.borderWidth = 0.5;
    //编辑按钮

    self.editButton = [self buttonWithText:@"编 辑" textColor:YellowColor fontSize:16 textAlignment:UIControlContentHorizontalAlignmentCenter backgroundColor:rearrangeBtnColor];
    [self.contentView addSubview:self.editButton];
    self.editButton.layer.cornerRadius = 5;
    self.editButton.layer.borderColor = YellowColor.CGColor;
    self.editButton.layer.borderWidth = 0.5;
    
    self.editButton.frame = CGRectMake(screenWidth - 180 * kWidth, CGRectGetMinY(label.frame) + 10 * kHeight, 72 * kHeight, 30 * kHeight);
    
}

-(UILabel *)labelWithBackgroundColor:(UIColor *)backgroundColor textColor:(UIColor *)textColor textAlignment:(NSTextAlignment)textAlignment numberOfLines:(NSInteger)integer text:(NSString *)text fontSize:(CGFloat)size
{
    
    UILabel *label = [[UILabel alloc]init];
    label.backgroundColor = backgroundColor;
    label.textColor = textColor;
    label.numberOfLines = integer;
    label.textAlignment = textAlignment;
    label.font = [UIFont systemFontOfSize:size];
    label.text = text;
    
    return label;
}

-(UIButton *)buttonWithText:(NSString *)text textColor:(UIColor *)textColor fontSize:(CGFloat)size textAlignment:(UIControlContentHorizontalAlignment)textAlignment backgroundColor:(UIColor *)backgroundColor
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setTitle:text forState:UIControlStateNormal];
    [button setTitleColor:textColor forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:size];
    button.contentHorizontalAlignment = textAlignment;
    button.backgroundColor = backgroundColor;
    
    return button;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
